var t = getApp();

Page({
    data: {
        cstoreId: null,
        commentType: 0,
        commentName: "评价类型",
        commentTypeShow: !1,
        commentTypeArr: [ {
            name: "推荐",
            value: 3
        }, {
            name: "一般",
            value: 2
        }, {
            name: "不推荐",
            value: 1
        } ],
        isLoadMore: !0,
        page: 1,
        totalPage: 0,
        commentList: []
    },
    onLoad: function(t) {
        var a;
        "" !== (null !== (a = t.storeId) && void 0 !== a ? a : "") && (this.setData({
            cstoreId: parseInt(t.storeId)
        }), this.storeGoodsList());
    },
    assessmentType: function() {
        this.setData({
            commentTypeShow: !this.data.commentTypeShow
        });
    },
    commentTypeOn: function(t) {
        var a = t.currentTarget.dataset.value, e = t.currentTarget.dataset.name;
        this.setData({
            commentType: a,
            commentName: e,
            commentTypeShow: !1
        }), this.storeGoodsList();
    },
    storeGoodsList: function() {
        var a = this, e = t.getNetAddresss("plugin.coupon-store.frontend.store-manage.commentList"), o = {
            cstore_id: this.data.cstoreId,
            page: this.data.page,
            comment_type: this.data.commentType
        };
        t._postNetWork({
            url: e,
            data: o,
            success: function(t) {
                var e = t.data;
                wx.hideLoading(), wx.hideNavigationBarLoading(), wx.stopPullDownRefresh(), 1 == e.result ? (console.log(e), 
                a.data.isLoadMore = !0, a.data.totalPage = e.data.last_page, a.data.totalPage || (a.data.totalPage = 0), 
                a.setData({
                    commentList: e.data.data
                })) : (a.data.page = a.data.page - 1, a.isLoadMore = !1, wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.totalPage)) {
            this.data.page = this.data.page + 1;
            var e = t.getNetAddresss("plugin.coupon-store.frontend.store-manage.commentList"), o = {
                store_id: this.data.cstoreId,
                page: this.data.page
            };
            t._getNetWork({
                url: e,
                data: o,
                success: function(t) {
                    var e = t.data, o = e.data.data;
                    1 == e.result ? (a.data.isLoadMore = !0, a.setData({
                        commentList: a.data.commentList.concat(o)
                    })) : (a.data.page = a.data.page - 1, a.isLoadMore = !1, wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    previewImage: function(t) {
        var a = t.currentTarget.dataset, e = a.images, o = a.src;
        wx.previewImage({
            current: o,
            urls: e
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        wx.showNavigationBarLoading(), wx.showLoading({
            title: "刷新中..."
        }), this.setData({
            commentType: 0,
            commentName: "评价类型"
        }), this.storeGoodsList();
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {}
});